<%--
  Created by IntelliJ IDEA.
  User: CHJYPC
  Date: 2021/6/20
  Time: 17:15
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>我的班级</title>
    <script src="${rootPath}resources/js/jquery.min.js"></script>
    <link rel="stylesheet" type="text/css" href="${rootPath}resources/css/myclazz.css">
</head>
<body style="background-color: white" onload=" init('${member.memberid}') ">
<div><h1>课程列表</h1></div>
<div id="clazzlist">

</div>
<div style="display: none">
    <form id="toViewClassDESC" action="ClazzMemberServlet" method="post">
        <input name="clazzid" id="inputClazzid">
        <input name="clazzname" id="inputClazzname">
        <input type="submit" value="提交">
    </form>
</div>
</body>
<script type="text/javascript">
    function init(memberid) {
        $.get("ClazzInitServlet?memberid=" + memberid, function (data, status) {
            // alert("数据: " + data + "\n状态: " + status);
            var dataJson = JSON.parse(data);

            var $ul = $("<ul id=\"clazzUL\"\>");
            $ul.appendTo("#clazzlist");//把新创建的ul元素放入div内部，并且放入div的最后//使用其他可以放到最前
            $.each(dataJson, function (index, clazz) {
                var $li = $("<li id=\"clazzULli\"   onclick=\" submit("+clazz.clazzid+",'"+clazz.clazzname+"');\"  \>");
                var $a = $("<p id=\"pclazzname\" >" + clazz.clazzname + "</p>" + "<p id=\"pclazzid\">" + "课程编号：" + clazz.clazzid + "</p>");
                $a.appendTo($li);
                $ul.append($li);
            });
        });
    }

    function submit(clazzid,clazzname) {
        // alert(clazzid +clazzname);

        $("#inputClazzid").val(clazzid);
        $("#inputClazzname").val(clazzname);

        $("#toViewClassDESC").submit();

        // $("#changeView").attr("src", "clazzdesc.jsp");

    }


</script>
</html>
